import ajax from '@/utils/ajax'


export const save = function (quartzJob) {
    return ajax.post('/sys/quartz/save', quartzJob)
}
export const pause = function (id) {
    return ajax.post('/sys/quartz/pauseJob',  {id: id},true)
}
export const resume = function (id) {
    return ajax.post('/sys/quartz/resumeJob', {id: id},true)
}
export const load = function (id) {
    return ajax.post('/sys/quartz/loadMore', {id: id}, true)
}
export const run = function (id) {
    return ajax.post('/sys/quartz/runJob', {id: id}, true)
}
export const del = function (id) {
    return ajax.post('/sys/quartz/delete', {id: id}, true)
}

export const getAllRunningJob = function () {
    return ajax.post('/sys/quartz/getAllRunningJob')
}

/**
 * 加载列表
 * @param tblOpts 列表信息
 * @param conditions 条件
 * @returns {*}
 */
export const pagination = function (tblOpts, conditions) {
    let params = {
        pageNo: tblOpts.pageNo || 1,
        pageSize: tblOpts.pageSize || 50,
        conditions: conditions || []
    }
    if (tblOpts.prop) {
        Object.assign(params, {
            sort: tblOpts.prop,
            order: tblOpts.order === 'descending' ? 'desc' : 'asc'
        })
    }
    return ajax.post('/sys/quartz/pagination', params, false)
}
